import { Component, OnInit } from '@angular/core';
import { AuthService } from 'src/app/service/auth.service';
import { Router } from '@angular/router';

@Component({
  selector: 'app-me-page',
  templateUrl: './me-page.component.html',
  styleUrls: ['./me-page.component.css']
})
export class MePageComponent implements OnInit {

  constructor(
    private authService: AuthService,
    private router: Router
    ) { }

  myUsername: string = "default";

  ngOnInit(): void {
    this.authService.getMe().subscribe((data: any) => {
      this.myUsername = data.current_user.username;
    })
  }

  logout(): void {
    localStorage.setItem('token', "")
    this.router.navigateByUrl('/login/login-page');
  }

}
